<?php
use Framework\Module\ModuleManager;
use ServiceAgent\API\IServiceTest;

/**
 * 主要测试远程调用，其他调用都测试完成了。
 *
 * @author Hoheart
 *        
 */
class ServiceAgentTest extends PHPUnit_Framework_TestCase {

	protected function setUp () {
		require_once (dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Framework' . DIRECTORY_SEPARATOR . 'App.php');
		
		$app = Framework\App::Instance();
	}

	public function testRemoteCallNoParam () {
		ModuleManager::Instance()->preloadModule('test');
		
		$sa = ModuleManager::Instance()->get('serviceAgent');
		$s = $sa->getService(IServiceTest::class);
		
		$ret = $s->testNoParam();
		if ('NoParam' !== $ret) {
			$this->fail('错误：测试远程服务的无参数调用失败。');
		}
	}

	public function testRemoteCallParam () {
		$sa = ModuleManager::Instance()->get('serviceAgent');
		$s = $sa->getService(IServiceTest::class);
		
		$params = array(
			'13' => 13666,
			'14' => 'abc'
		);
		$ret = $s->testParam($params);
		if ($params !== $ret) {
			$this->fail('错误：测试远程服务的有参数调用失败。');
		}
	}
}